package o;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ListView;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.exposure.bean.ExposureDetail;
import java.util.ArrayList;
import java.util.List;

public class dyk {
    private int ˊ = ccz.ॱ();
    private long ˋ;
    private ListView ˎ;
    private a ॱ;

    class a extends SomeTimerTask {
        private int ˏ;
        final /* synthetic */ dyk ॱ;

        public a(dyk o_dyk, int i) {
            this.ॱ = o_dyk;
            this.ˏ = i;
        }

        protected int[] getVisibleImtePos() {
            int[] iArr = new int[]{-1, -1};
            if (this.ॱ.ˎ != null) {
                iArr[0] = this.ॱ.ˎ.getFirstVisiblePosition();
                iArr[1] = this.ॱ.ˎ.getLastVisiblePosition();
            }
            return iArr;
        }

        protected boolean ˎ(int i) {
            View ˏ = ˏ(i);
            if (ˏ == null) {
                return false;
            }
            cht o_cht;
            Object tag = ˏ.getTag();
            if (tag instanceof cht) {
                o_cht = (cht) tag;
            } else {
                o_cht = null;
            }
            if (o_cht == null) {
                return false;
            }
            if (o_cht.ʽ()) {
                return true;
            }
            return super.ˎ(i);
        }

        protected View ˏ(int i) {
            return this.ॱ.ˎ.getChildAt(i - this.ॱ.ˎ.getFirstVisiblePosition());
        }

        protected List<ExposureDetail> ˏ(int i, int i2) {
            Object obj = evt.ˊ(this.ॱ.ˎ) >= 50 ? 1 : null;
            ArrayList arrayList = new ArrayList();
            if (obj == null) {
                return arrayList;
            }
            while (i <= i2) {
                View ˏ = ˏ(i);
                if (ˏ != null) {
                    cht o_cht = (cht) ˏ.getTag();
                    if (o_cht != null && o_cht.ˏॱ()) {
                        ArrayList z_;
                        ExposureDetail exposureDetail = new ExposureDetail();
                        ArrayList arrayList2 = new ArrayList();
                        if (o_cht.ॱ()) {
                            z_ = o_cht.z_();
                        } else {
                            int ˊॱ = o_cht.ˊॱ();
                            for (int i3 = 0; i3 < ˊॱ; i3++) {
                                cih ˎ = o_cht.ˎ(i3);
                                if (ˋ(ˎ)) {
                                    CardBean ˌ = ˎ.ˌ();
                                    if (ˌ != null) {
                                        if (ˌ instanceof BaseCardBean) {
                                            arrayList2.add(ˌ.ॱॱ() + "#$#" + ((BaseCardBean) ˌ).u_());
                                        } else {
                                            arrayList2.add(ˌ.ॱॱ());
                                        }
                                    }
                                }
                            }
                            z_ = arrayList2;
                        }
                        z_ = ॱ(z_, o_cht);
                        if (!CollectCheck.isEmpty((List) z_)) {
                            exposureDetail.ˎ(z_);
                            exposureDetail.ॱ(String.valueOf(o_cht.ˏ));
                            exposureDetail.ˏ(System.currentTimeMillis());
                            arrayList.add(exposureDetail);
                            ˊ(arrayList, o_cht);
                        }
                    }
                }
                i++;
            }
            return arrayList;
        }

        private boolean ˋ(cih o_cih) {
            if (o_cih != null) {
                View ˉ = o_cih.ˉ();
                if (ˉ != null && ˉ.getVisibility() == 0) {
                    return true;
                }
            }
            return false;
        }

        private ArrayList<String> ॱ(ArrayList<String> arrayList, cht o_cht) {
            List ˋॱ = o_cht.ˋॱ();
            if (CollectCheck.isEmpty((List) arrayList) && CollectCheck.isEmpty(ˋॱ)) {
                return null;
            }
            if (CollectCheck.isEmpty((List) arrayList)) {
                return ˋॱ;
            }
            if (CollectCheck.isEmpty(ˋॱ)) {
                return arrayList;
            }
            arrayList.addAll(ˋॱ);
            return arrayList;
        }

        private void ˊ(ArrayList<ExposureDetail> arrayList, cht o_cht) {
            if ((o_cht instanceof cdr) && ((cdr) o_cht).ʻ() && ((cdr) o_cht).ॱॱ() != null) {
                ExposureDetail exposureDetail = new ExposureDetail();
                ArrayList z_ = o_cht.z_();
                if (!CollectCheck.isEmpty((List) z_)) {
                    exposureDetail.ˎ(z_);
                    exposureDetail.ॱ(String.valueOf(((cdr) o_cht).ॱॱ().ˏ));
                    exposureDetail.ˏ(System.currentTimeMillis());
                    arrayList.add(exposureDetail);
                }
            }
        }

        protected long ˊ() {
            return this.ॱ.ˋ;
        }

        protected int ˋ() {
            return this.ˏ;
        }
    }

    public dyk(ListView listView) {
        this.ˎ = listView;
        if (this.ˎ != null) {
            this.ˊ = dgm.ˎ((Activity) this.ˎ.getContext());
        }
    }

    public dyk(int i) {
        this.ˊ = i;
    }

    public void ॱ() {
        this.ˋ = System.currentTimeMillis();
        this.ॱ = new a(this, this.ˊ);
        this.ॱ.ˏ();
    }

    public void ॱ(BaseCardBean baseCardBean) {
        if (!dof.ॱ(baseCardBean.ॱॱ())) {
            dyg ॱ = dyg.ॱ();
            ExposureDetail exposureDetail = new ExposureDetail();
            exposureDetail.ˏ(System.currentTimeMillis());
            exposureDetail.ॱ(baseCardBean.ॱˉ());
            ArrayList arrayList = new ArrayList();
            arrayList.add(baseCardBean.ॱॱ() + "#$#" + baseCardBean.u_());
            exposureDetail.ˎ(arrayList);
            int i = this.ˊ;
            if (this.ˎ != null) {
                i = dgm.ˎ((Activity) this.ˎ.getContext());
            }
            ॱ.ˎ(exposureDetail, i);
        }
    }

    public void ॱ(BaseCardBean baseCardBean, String str) {
        if (!dof.ॱ(baseCardBean.ॱॱ())) {
            dyg ॱ = dyg.ॱ();
            ExposureDetail exposureDetail = new ExposureDetail();
            exposureDetail.ˏ(System.currentTimeMillis());
            exposureDetail.ॱ(baseCardBean.ॱˉ());
            ArrayList arrayList = new ArrayList();
            if (dof.ॱ(str)) {
                arrayList.add(baseCardBean.ॱॱ() + "#$#" + baseCardBean.u_());
            } else {
                arrayList.add(str);
            }
            exposureDetail.ˎ(arrayList);
            int i = this.ˊ;
            if (this.ˎ != null) {
                i = dgm.ˎ((Activity) this.ˎ.getContext());
            }
            ॱ.ˎ(exposureDetail, i);
        }
    }

    public static void ॱ(Context context, String str, String str2) {
        if ((context instanceof Activity) && !TextUtils.isEmpty(str2)) {
            dyg ॱ = dyg.ॱ();
            ExposureDetail exposureDetail = new ExposureDetail();
            exposureDetail.ˏ(System.currentTimeMillis());
            exposureDetail.ॱ(str);
            ArrayList arrayList = new ArrayList();
            arrayList.add(str2);
            exposureDetail.ˎ(arrayList);
            ॱ.ˎ(exposureDetail, dgm.ˎ((Activity) context));
        }
    }

    public static void ॱ(boolean z) {
        dyf.ˎ(z);
    }

    public static String ˏ(@NonNull cgz o_cgz) {
        CardBean ˌ = o_cgz.ˌ();
        if (ˌ == null || TextUtils.isEmpty(ˌ.ॱॱ())) {
            return null;
        }
        if (ˌ instanceof BaseCardBean) {
            return ˌ.ॱॱ() + "#$#" + ((BaseCardBean) ˌ).u_();
        }
        return ˌ.ॱॱ();
    }
}
